﻿

'*******************************************************************
' Program: Data Center Visio Rack Tool
' Author: Albert E Edlund
' Date:
'
' Purpose:
'
'
'
'*******************************************************************


Imports Microsoft.Practices.EnterpriseLibrary.Common
Imports Microsoft.Practices.EnterpriseLibrary.Data
Imports Microsoft.Practices.EnterpriseLibrary.ExceptionHandling
Imports Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging


Imports System
Imports System.ComponentModel
Imports System.Collections.Generic



Public Class dc_Application
    Implements INotifyPropertyChanged



#Region "Events"

    Public Event PropertyChanged(ByVal sender As Object, ByVal e As System.ComponentModel.PropertyChangedEventArgs) _
        Implements System.ComponentModel.INotifyPropertyChanged.PropertyChanged

    Private Sub OnPropertyChanged(ByVal info As String)
        RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(info))
    End Sub

#End Region

#Region " Constructor "

    Public Sub New()
        initProperties()
    End Sub

    Public Sub New(ByVal strUserId As String)
        initProperties()
        Me.m_appLastEdit = strUserId
    End Sub

#End Region

#Region " Enumerations "


    Public Enum appType
        Unknown
        System
        User
    End Enum

    Public Enum appAvailability
        Unknown
        Critical
        High
        Medium
        Low
    End Enum

    Public Enum appImpact
        Unknown
        High
        Medium
        Low
    End Enum

    Public Enum appFocus
        Unknown
        Internal
        External
    End Enum



    ' shapes from visio server stencil
    ' a couple of the real names have embedded hyphens
    ' most have embedded spaces
    Public Enum appVisioShape
        server
        email_server
        file_server
        web_server
        proxy_server
        realtime_communications_server
        ecommerce_server
        database_server
        content_management_server
        ftp_server
        streaming_media_server
        management_server
        directory_server
        print_server
        mobile_information_server
        application_server
    End Enum


#End Region

#Region " Properties and Fields "


    Private m_appKey As Int32
    Public Const constappKey As Int32 = -1
    Public Property appKey() As Int32
        Get
            Return Me.m_appKey
        End Get
        Set(ByVal value As Int32)
            Me.m_appKey = value
            Me.OnPropertyChanged("appKey")
        End Set
    End Property

    Private m_appName As String
    Public Const constappName As String = "na"
    Public Property appName() As String
        Get
            Return Me.m_appName
        End Get
        Set(ByVal value As String)
            Me.m_appName = value
            Me.OnPropertyChanged("appName")
        End Set
    End Property

    Private m_appVendor As String
    Public Const constappVendor As String = "na"
    Public Property appVendor() As String
        Get
            Return Me.m_appVendor
        End Get
        Set(ByVal value As String)
            Me.m_appVendor = value
            Me.OnPropertyChanged("appVendor")
        End Set
    End Property

    Private m_appVersion As String
    Public Const constappVersion As String = "na"
    Public Property appVersion() As String
        Get
            Return Me.m_appVersion
        End Get
        Set(ByVal value As String)
            Me.m_appVersion = value
            Me.OnPropertyChanged("appVersion")
        End Set
    End Property

    Private m_appServicePack As String
    Public Const constappServicePack As String = "na"
    Public Property appServicePack() As String
        Get
            Return Me.m_appServicePack
        End Get
        Set(ByVal value As String)
            Me.m_appServicePack = value
            Me.OnPropertyChanged("appServicePack")
        End Set
    End Property

    Private m_appFixLevel As String
    Public Const constappFixLevel As String = "na"
    Public Property appFixLevel() As String
        Get
            Return Me.m_appFixLevel
        End Get
        Set(ByVal value As String)
            Me.m_appFixLevel = value
            Me.OnPropertyChanged("appFixLevel")
        End Set
    End Property

    Private m_appOSKey As Int32 'the operating system associated
    Public Const constAppOSKey As Int32 = -1
    Public Property appOSKey() As Int32
        Get
            Return Me.m_appOSKey
        End Get
        Set(ByVal value As Int32)
            Me.m_appOSKey = value
            Me.OnPropertyChanged("appOSKey")
        End Set
    End Property

    Private m_appUserCommunity As String
    Public Const constappUserCommunity As String = "na"
    Public Property appUserCommunity() As String
        Get
            Return Me.m_appUserCommunity
        End Get
        Set(ByVal value As String)
            Me.m_appUserCommunity = value
            Me.OnPropertyChanged("appUserCommunity")
        End Set
    End Property

    Private m_appOwner As String
    Public Const constappOwner As String = "na"
    Public Property appOwner() As String
        Get
            Return Me.m_appOwner
        End Get
        Set(ByVal value As String)
            Me.m_appOwner = value
            Me.OnPropertyChanged("appOwner")
        End Set
    End Property

    Private m_appMove As Boolean ' will this application move with datacenter
    Public Const constappMove As Boolean = True
    Public Property appMove() As Boolean
        Get
            Return Me.m_appMove
        End Get
        Set(ByVal value As Boolean)
            Me.m_appMove = value
            Me.OnPropertyChanged("appMove")
        End Set
    End Property

    Private m_appOwnerSignOff As Boolean ' does user say it is ready to move
    Public Const constappOwnerSignoff As Boolean = False
    Public Property appOwnerSignOff() As Boolean
        Get
            Return Me.m_appOwnerSignOff
        End Get
        Set(ByVal value As Boolean)
            Me.m_appOwnerSignOff = value
            Me.OnPropertyChanged("appOwnerSignOff")
        End Set
    End Property

    Private m_appOwnerSignOffDate As DateTime
    Public Const constappOwnerSignoffDate As Date = #1/1/2001#
    Public Property appOwnerSignOffDate() As DateTime
        Get
            Return Me.m_appOwnerSignOffDate
        End Get
        Set(ByVal value As DateTime)
            Me.m_appOwnerSignOffDate = value
            Me.OnPropertyChanged("appOwnerSignOffDate")
        End Set
    End Property

    Private m_appSystemOrUser As appType
    Public Const constappSystemOrUser As appType = appType.User
    Public Property appSystemOrUser() As appType
        Get
            Return Me.m_appSystemOrUser
        End Get
        Set(ByVal value As appType)
            Me.m_appSystemOrUser = value
            Me.OnPropertyChanged("appSystemOrUser")
        End Set
    End Property

    Private m_appAvailabilityTarget As appAvailability
    Public Const constappAvailabilityTarget As appAvailability = appAvailability.Medium
    Public Property appAvailabilityTarget() As appAvailability
        Get
            Return Me.m_appAvailabilityTarget
        End Get
        Set(ByVal value As appAvailability)
            ' Checks to see if the value passed is valid.
            If Not TypeDescriptor.GetConverter(GetType(appAvailability)).IsValid(value) Then
                ' Throw New ArgumentException()
                value = appAvailability.Unknown
            End If
            Me.m_appAvailabilityTarget = value
            Me.OnPropertyChanged("appAvailabilityTarget")
        End Set
    End Property

    Private m_appOperationalImpact As appImpact
    Public Const constappOperationalImpact As appImpact = appImpact.Low
    Public Property appOperationalImpact() As appImpact
        Get
            Return Me.m_appOperationalImpact
        End Get
        Set(ByVal value As appImpact)
            ' Checks to see if the value passed is valid.
            If Not TypeDescriptor.GetConverter(GetType(appImpact)).IsValid(value) Then
                ' Throw New ArgumentException()
                value = appImpact.Unknown
            End If
            Me.m_appOperationalImpact = value
            Me.OnPropertyChanged("appOperationalImpact")
        End Set
    End Property

    ' this is a visio master shape name
    ' chris roth has a great tool for creating custom shapes
    ' http://www.visguy.com/2009/09/11/visio-server-shape-icon-customization-tool/
    '
    Private m_appShape As String
    Public Const constappShape As String = "server"
    Public Property appShape As String
        Get
            Return Me.m_appShape
        End Get
        Set(ByVal value As String)
            Me.m_appShape = value
        End Set
    End Property

    Private m_appHoursOfOperations As String
    Public Const constappHoursOfOperations As String = "m-f"   ' free form text - not checked
    Public Property appHoursOfOperations() As String
        Get
            Return Me.m_appHoursOfOperations
        End Get
        Set(ByVal value As String)
            Me.m_appHoursOfOperations = value
            Me.OnPropertyChanged("appHoursOfOperation")
        End Set
    End Property

    Private m_appPeered As Boolean ' does this peer to another application
    Public Const constappPeered As Boolean = False
    Public Property appPeered() As Boolean
        Get
            Return Me.m_appPeered
        End Get
        Set(ByVal value As Boolean)
            Me.m_appPeered = value
            Me.OnPropertyChanged("appPeered")
        End Set
    End Property


    Private m_appIntExt As appFocus  ' does this go external 
    Public Const constappIntExt As appFocus = appFocus.Internal
    Public Property appIntExt() As appFocus
        Get
            Return Me.m_appIntExt
        End Get
        Set(ByVal value As appFocus)
            ' Checks to see if the value passed is valid.
            If Not TypeDescriptor.GetConverter(GetType(appFocus)).IsValid(value) Then
                ' Throw New ArgumentException()
                value = appFocus.Unknown
            End If
            Me.m_appIntExt = value
            Me.OnPropertyChanged("appIntExt")
        End Set
    End Property

    Private m_appNetworkProtocol As String ' list of network protocols used
    Public Const constappNetworkProtocol As String = "[tcpip]"
    Public Property appNetworkProtocol() As String
        Get
            Return Me.m_appNetworkProtocol
        End Get
        Set(ByVal value As String)
            Me.m_appNetworkProtocol = value
            Me.OnPropertyChanged("appNetworkProtocol")
        End Set
    End Property

    Private m_appHardCodeIpAddresses As String ' "[]"  csv list of ipaddresses used and touched
    Public Const constappHardCodeIpAddress As String = "[0.0.0.0]"
    Public Property appHardCodeIpAddresses() As String
        Get
            Return Me.m_appHardCodeIpAddresses
        End Get
        Set(ByVal value As String)
            Me.m_appHardCodeIpAddresses = value
            Me.OnPropertyChanged("appHardCodeIpAddresses")
        End Set
    End Property

    Private m_appIpPorts As String ' "[]"  csv list of ports used
    Public Const constappIpPorts As String = "[]"
    Public Property appIpPorts() As String
        Get
            Return Me.m_appIpPorts
        End Get
        Set(ByVal value As String)
            Me.m_appIpPorts = value
            Me.OnPropertyChanged("appIpPorts")
        End Set
    End Property

    Private m_appHardCodeMac As String ' does it use a netbios hard coded mac address
    Public Const constappHardCodedMac As String = "[0123456789ab]"
    Public Property appHardCodeMac() As String
        Get
            Return Me.m_appHardCodeMac
        End Get
        Set(ByVal value As String)
            Me.m_appHardCodeMac = value
            Me.OnPropertyChanged("appHardCodeMac")
        End Set
    End Property

    Private m_appComments As String
    Public Const constappComments As String = "none"
    Public Property appComments() As String
        Get
            Return Me.m_appComments
        End Get
        Set(ByVal value As String)
            Me.m_appComments = value
            Me.OnPropertyChanged("appComments")
        End Set
    End Property

    Private m_appLastUpdate As DateTime
    Public Const constappLastUpdate As Date = #1/1/2001#
    Public Property appLastUpdate() As DateTime
        Get
            Return Me.m_appLastUpdate
        End Get
        Set(ByVal value As DateTime)
            Me.m_appLastUpdate = value
            Me.OnPropertyChanged("appLastUpdate")
        End Set
    End Property

    Private m_appLastEdit As String
    Public Const constappLastEdit As String = ""
    Public Property appLastEdit() As String
        Get
            Return Me.m_appLastEdit
        End Get
        Set(ByVal value As String)
            Me.m_appLastEdit = value
            Me.OnPropertyChanged("appLastEdit")
        End Set
    End Property


#End Region

#Region " Methods "


    Public Sub initProperties()

        Try
            appKey = constappKey
            appOSKey = constappOsKey
            appName = constappName
            appVendor = constappVendor
            appVersion = constappVersion
            appServicePack = constappServicePack
            appFixLevel = constappFixLevel
            appUserCommunity = constappUserCommunity
            appOwner = constappOwner
            appMove = constappMove
            appOwnerSignOff = constappOwnerSignoff
            appOwnerSignOffDate = constappOwnerSignoffDate
            appSystemOrUser = constappSystemOrUser
            appAvailabilityTarget = constappAvailabilityTarget
            appOperationalImpact = constappOperationalImpact
            appShape = constappShape
            appHoursOfOperations = constappHoursOfOperations
            appPeered = constappPeered
            appIntExt = constappIntExt
            appNetworkProtocol = constappNetworkProtocol
            appHardCodeIpAddresses = constappHardCodeIpAddress
            appIpPorts = constappIpPorts
            appHardCodeMac = constappHardCodedMac
            appComments = constappComments
            appLastUpdate = Now
            appLastEdit = constappLastEdit


        Catch ex As Exception
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(ex, "Log Only Policy")
            If (rethrow) Then
                Throw
            End If
        End Try

    End Sub




#End Region


End Class


